package main

import (
	"github.com/gin-gonic/gin"
	_ "github.com/go-sql-driver/mysql"
	"net/http"
	"ylb/config"
	"ylb/controller"
	"ylb/mycron"
)

func main() {
	ginServer := gin.Default()

	//静态资源
	dir := http.Dir("./static")
	ginServer.StaticFS("/static", dir)
	ginServer.LoadHTMLGlob("./static/html/*.html")

	ginServer.NoRoute(config.Handle404Html)
	initServer(ginServer)
	ginServer.Run(":8081")
}
func initServer(ginServer *gin.Engine) {
	server := mycron.StartCronServer(ginServer)
	server.Start()
	RegisterRouter(ginServer)
}
func RegisterRouter(ginServer *gin.Engine) {
	controller.NewUserController(ginServer)

	controller.NewJobController(ginServer)

	testController := controller.TestController{}
	testController.TestRouter(ginServer)

	controller.NewEmailController(ginServer)

	controller.NewNoteController(ginServer)
}
